package cn.lichenes.service.impl;

import cn.lichenes.entity.Evaluate;
import cn.lichenes.entity.Indent;
import cn.lichenes.repository.EvaluateRepository;
import cn.lichenes.repository.IndentRepository;
import cn.lichenes.service.EvaluateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

@Service
public class EvaluateServiceImpl implements EvaluateService{

    @Autowired
    private EvaluateRepository evaluateRepository;
    @Autowired
    private IndentRepository indentRepository;

    @Override
    public boolean add(Integer oid, String content) {
        Indent indent = indentRepository.findById(oid).get();
        indent.setoStatus(4);
        Evaluate evaluate = new Evaluate();
        evaluate.seteContent(content);
        evaluate.seteTime(new Date());
        evaluate.setIndent(indent);
        Evaluate save = evaluateRepository.save(evaluate);
        if (save != null){
            return true;
        }
        return false;
    }
}
